package ai;


public class PossibleAssignment implements Sortable {

	public Task task;
	public TaskDoer possibleTaskDoer;
	public short score;

	public PossibleAssignment(Task task, TaskDoer possibleTaskDoer) {
		this.task = task;
		this.possibleTaskDoer = possibleTaskDoer;
		setScore();
	}

	private void setScore() {
		short eta = (short) possibleTaskDoer.getETA();
		if (eta == 0)
			eta = 1;
		this.score = (short) FuzzyEngineFactory.getResAllocFuzzyEngine()
				.defuzzify(task.getFormula(possibleTaskDoer), eta);
	}

	public boolean leq(Object compareTo) {
		return this.score >= ((PossibleAssignment) compareTo).score;
	}

	public String toString() {
		return new StringBuffer("- score ").append(score).append("=priority ")
				.append(task.getFormula(possibleTaskDoer)).append(" : (").append(task.id).append(
						") ").append(task.name).append(" ").append(task.target)
				.append(" possibleTaskDoer ").append(possibleTaskDoer).append(
						"\n").toString();
	}

}
